home *** CD-ROM | disk | FTP | other *** search
/ Columbia Kermit / kermit.zip / newsgroups / misc.20041116-20060924 / 000361_fdc@columbia.edu_Tue Jun 20 10:42:52 2006.msg < prev    next >
Text File  |  2020-01-01  |  4KB  |  110 lines

  1. Path: newsmaster.cc.columbia.edu!not-for-mail
  2. From: Frank da Cruz <fdc@columbia.edu>
  3. Newsgroups: comp.protocols.kermit.misc
  4. Subject: Re: Assigning output from LINEOUT to a variable
  5. Date: 20 Jun 2006 14:39:38 GMT
  6. Organization: Columbia University
  7. Lines: 93
  8. Message-ID: <slrne9g25a.h41.fdc@sesame.cc.columbia.edu>
  9. References: <1150811644.629253.47720@r2g2000cwb.googlegroups.com>
  10. Reply-To: fdc@columbia.edu
  11. NNTP-Posting-Host: sesame.cc.columbia.edu
  12. X-Trace: newsmaster.cc.columbia.edu 1150814378 11518 128.59.59.56 (20 Jun 2006 14:39:38 GMT)
  13. X-Complaints-To: postmaster@columbia.edu
  14. NNTP-Posting-Date: 20 Jun 2006 14:39:38 GMT
  15. User-Agent: slrn/0.9.8.0 (SunOS)
  16. Xref: newsmaster.cc.columbia.edu comp.protocols.kermit.misc:15618
  17.  
  18. On 2006-06-20, toastyboy@googlemail.com <toastyboy@googlemail.com> wrote:
  19. From: Frank da Cruz <fdc@sesame.cc.columbia.edu>
  20. To: toastyboy@googlemail.com
  21. Subject: Re: Assigning output from LINEOUT to a variable
  22. In-Reply-To: <1150811644.629253.47720@r2g2000cwb.googlegroups.com>
  23.  
  24. : I'm using kermit to control a quasar electronics 3108 serial module, at
  25. : present I am calling the kermit script i have written from a bash shell
  26. : script and it works ok, but it is inefficient.
  27. : I'm hoping to write the whole thing inside a kermit script, however I'm
  28. : stuck....
  29. : I can read in a file and then assign the value contained in that file
  30. : to a variable that works a treat!  See below:
  31. : OPEN READ /u01/status/OUT58
  32. : READ \%a
  33. : close read-file
  34. : if ( == \%a 0 ) {
  35. :         LINEOUT F1
  36. :         INPUT 5 \"#\"
  37. : } else {
  38. :         LINEOUT N1
  39. :         INPUT 5 \"#\"
  40. : }
  41. : As I say that works well, however I need to be able to do (say)
  42. : LINEOUT I1
  43. : which will give me the status of input line 1 and then take the output
  44. : of this and if it is 1 then do something, if it is 0 then do something
  45. : else.
  46. : So I need something like:
  47. : LINEOUT I1   > \%a
  48. : INPUT 5 \"#\"
  49. : if ( == \%a 0 ) {
  50. :         echo 1 > IN11
  51. : } else {
  52. :         echo 0 > IN11
  53. : }
  54. : ...but I've just made up the syntax of the fist line "LINEOUT I1   >
  55. : \%a"  I need to know how to inject the output of this command to a
  56. : variable.
  57. First let's assume you're using the current version of C-Kermit, 8.0:
  58.  
  59.   http://www.columbia.edu/kermit/ckermit.html
  60.  
  61. If not, you should pick it up.  Then see:
  62.  
  63.   http://www.columbia.edu/kermit/ckscripts.html
  64.  
  65. about how to construct a Kermit script that you can run directly from
  66. the shell, as if it were a shell script.  Remember to put in IF FAIL or
  67. IF SUCCESS tests after critical commands after which you don't want the
  68. script to keep going if they fail: 
  69.  
  70.   #!/usr/local/bin/kermit
  71.   .file := /u01/status/OUT58
  72.   open read \m(file)
  73.   if fail exit 1 "?\m(file): Open failed"
  74.   read \%a
  75.   if fail exit 1 "?\m(file): Read failed"
  76.   close read-file
  77.   if == \%a 0 lineout F1
  78.   else lineout N1
  79.   input 5 \"#\"
  80.   if fail exit 1 "?INPUT timed out"
  81.  
  82. Now the next part I'm not sure about.  You want to send "I1" and then read
  83. back the response into a variable.  I can show you how to do that but first
  84. you have to tell me how to parse the response.  Plus I'm not sure what
  85. you're trying to accomplish the with the ECHO commands.
  86.  
  87. Usually the pattern is, you do an OUTPUT to make the thing on the other
  88. end send some results, and then you do an INPUT to read the results.  Since
  89. you don't know what the results will be, the thing your INPUT command is
  90. looking for is a line terminator, or the next prompt, etc.  Then if the
  91. INPUT command succeeds, the \v(input) variable contains whatever was read
  92. by the INPUT command (and, in fact, previous ones too, unless you gave a
  93. CLEAR INPUT command before issuing the INPUT command)
  94.  
  95. Then you would use the Kermit's string processing functions such as
  96. \findex(), \fsubstring(), etc, to extract the desired item from the the
  97. \v(input) variable.
  98.  
  99. - Frank